package controller;

import java.io.IOException;
import java.util.ArrayList;

import model.UserProjectList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import db.DbConn;

public class History extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	DbConn conn;

	@Override
	public void init() throws ServletException {
		conn = new DbConn();
		conn.setDbUrl(getServletContext().getInitParameter("dbUrl"));
		conn.setDbUser(getServletContext().getInitParameter("dbUser"));
		conn.setDbPass(getServletContext().getInitParameter("dbPass"));
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String userId = (String)req.getSession().getAttribute("userId");
		ArrayList<UserProjectList> list = conn.getUserProjectList(userId);
		req.setAttribute("projectList", list);
		RequestDispatcher dispatcher = req.getRequestDispatcher("/logon/history.jsp");
		dispatcher.forward(req, resp);
	}
}
